﻿
using MediatR;
using Micro.Core.Packages;
using Micro.Extensions.DDD.Bus;
using Micro.Extensions.DDD.Events;
using Micro.Extensions.DDD.Notifications;
using Microsoft.AspNetCore.Builder;

namespace Microsoft.Extensions.DependencyInjection
{
    [DependsOnPacks(typeof(AutoMapperPack))]
    public class DDDPack : BasePackage
    {

        public override PackLevel Level => PackLevel.Framework;

        public override int Order => 1;

        public override IServiceCollection AddServices(IServiceCollection services)
        {
            services.AddMediatR(typeof(DDDPack));
            // 命令总线Domain Bus (Mediator)
            services.AddScoped<IMediatorHandler, MediatorHandler>();
            // 领域通知
            services.AddScoped<INotificationHandler<DomainNotification>, DomainNotificationHandler>();
            // 注入 基础设施层 - 事件溯源


            return base.AddServices(services);
        }


        public override void UsePack(WebApplication app)
        {
            //app.
            base.UsePack(app);
        }



    }
}